package br.com.iswe.gwt.ui.client;

import br.com.iswe.gwt.ui.client.menu.BarraMenuLateral;

import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Widget;

public class Estrutura extends FlexTable {

	private Widget topWidget 	= null;
	private Widget leftWidget 	= null;
	private Widget centerWidget = null;
	private Widget bottomWidget = null;
	
	public void setup(){
		//configuracoes gerais
		setHeight("100%");
		setWidth("760px");
		
		//Parte superior
		Widget temp = getTopWidget();
		if(temp != null){
			//Apenas enquanto nao existe barra superior...
			//FlexTable table = new FlexTable();
			//table.setWidth("100%");
			//table.setCellPadding(0);
			//table.setCellSpacing(0);
			//table.setWidget(0, 0 , temp);
			setWidget(0, 0, temp);
			getFlexCellFormatter().setColSpan(0, 0, 2);
			getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
		}
		//Menu Esquerdo
		temp = getLeftWidget();
		if(temp != null){
			setWidget(1, 0, new BarraMenuLateral(temp));
			getFlexCellFormatter().setHeight(1, 0, "100%");
		}
		//Parte central
		temp = getCenterWidget();
		if(temp != null){
			setWidget(1, 1, temp);
			getFlexCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
			getFlexCellFormatter().setHeight(1, 1, "100%");
		}
		//Parte inferior
		temp = getBottomWidget();
		if(temp != null){
			setWidget(2, 0, temp);
			getFlexCellFormatter().setColSpan(0, 0, 2);
		}
		
	}

	public Widget getBottomWidget() {
		return bottomWidget;
	}
	public void setBottomWidget(Widget bottomWidget) {
		this.bottomWidget = bottomWidget;
	}

	public Widget getCenterWidget() {
		return centerWidget;
	}
	public void setCenterWidget(Widget centerWidget) {
		this.centerWidget = centerWidget;
	}

	public Widget getLeftWidget() {
		return leftWidget;
	}
	public void setLeftWidget(Widget leftWidget) {
		this.leftWidget = leftWidget;
	}

	public Widget getTopWidget() {
		return topWidget;
	}
	public void setTopWidget(Widget topWidget) {
		this.topWidget = topWidget;
	}
}
